package cn.gson.springboot.model.pjos;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Collection;
import java.util.Objects;

@Entity
public class Returnorderdetails {
    private int rodId;//id
    private Integer rodNumber;//数量
    private BigDecimal rodAmount;//金额
    private Integer rodProdcutid;//产品id
    /*private Collection<Productside> productsidesByRodId;*/
    private Returnorder returnorderByRetuId;//退货单id

    @Id
    @Column(name = "rod_id")
    @GeneratedValue(strategy = GenerationType.IDENTITY,generator = "seq")
    public int getRodId() {
        return rodId;
    }

    public void setRodId(int rodId) {
        this.rodId = rodId;
    }

    @Basic
    @Column(name = "rod_number")
    public Integer getRodNumber() {
        return rodNumber;
    }

    public void setRodNumber(Integer rodNumber) {
        this.rodNumber = rodNumber;
    }

    @Basic
    @Column(name = "rod_amount")
    public BigDecimal getRodAmount() {
        return rodAmount;
    }

    public void setRodAmount(BigDecimal rodAmount) {
        this.rodAmount = rodAmount;
    }


    @Basic
    @Column(name = "rod_prodcutid")
    public Integer getRodProdcutid() {
        return rodProdcutid;
    }

    public void setRodProdcutid(Integer rodProdcutid) {
        this.rodProdcutid = rodProdcutid;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Returnorderdetails that = (Returnorderdetails) o;
        return rodId == that.rodId &&
                Objects.equals(rodNumber, that.rodNumber) &&
                Objects.equals(rodAmount, that.rodAmount) &&
                Objects.equals(rodProdcutid, that.rodProdcutid);
    }

    @Override
    public int hashCode() {
        return Objects.hash(rodId, rodNumber, rodAmount, rodProdcutid);
    }

    /*@OneToMany(mappedBy = "returnorderdetailsByRodId")
    public Collection<Productside> getProductsidesByRodId() {
        return productsidesByRodId;
    }

    public void setProductsidesByRodId(Collection<Productside> productsidesByRodId) {
        this.productsidesByRodId = productsidesByRodId;
    }*/

    @ManyToOne
    @JoinColumn(name = "retu_id", referencedColumnName = "retu_id")
    public Returnorder getReturnorderByRetuId() {
        return returnorderByRetuId;
    }

    public void setReturnorderByRetuId(Returnorder returnorderByRetuId) {
        this.returnorderByRetuId = returnorderByRetuId;
    }
}
